package com.yuan.weike.model;

/**
 * 用户状态枚举
 */
public enum UserStatusEnum {
    /**
     * 禁用
     */
    DISABLED(0, "禁用"),

    /**
     * 正常
     */
    NORMAL(1, "正常"),

    /**
     * 待邮箱验证
     */
    EMAIL_PENDING(2, "待邮箱验证");

    private final int value;
    private final String text;

    UserStatusEnum(int value, String text) {
        this.value = value;
        this.text = text;
    }

    public int getValue() {
        return value;
    }

    public String getText() {
        return text;
    }

    /**
     * 根据value获取枚举
     *
     * @param value 值
     * @return 枚举
     */
    public static UserStatusEnum fromValue(int value) {
        for (UserStatusEnum status : UserStatusEnum.values()) {
            if (status.value == value) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的用户状态值: " + value);
    }
}